package jdbc;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/7/31 9:57
 */
import java.sql.*;
import java.util.Scanner;

public class JDBC_Old_Login {
    public static void main(String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/teacher", "root", "root");
        Statement stmt = conn.createStatement();
        System.out.println("请输入名字：");
        String s1 = new Scanner(System.in).nextLine();
        System.out.println("请输入密码：");
        String s2 = new Scanner(System.in).nextLine();
        ResultSet resultSet = stmt.executeQuery("select * from login where name='"+s1+"' and password= '"+s2+"'");
        if (resultSet.next()){
            System.out.println("恭喜你,登录成功");
        }
        else {
            System.out.println("输入错误，请重新输入");
        }
        resultSet.close();
        stmt.close();
        conn.close();
    }
}